#include "myAes.h"

namespace daniel
{
    void MyAes::aesCbcEncrypt(uint8_t *in, uint8_t *out, uint32_t len)
    {
        AES_KEY realKey;
        AES_set_decrypt_key((uint8_t *)(m_key.c_str()), 128, &realKey);
        // len = (len % 16 == 0 ? len : (len / 16 + 1) * 16);
        AES_cbc_encrypt(in, out, len, &realKey, (uint8_t *)(m_ivec.c_str()), AES_ENCRYPT);
    }
    void MyAes::aesCbcDecrypt(uint8_t *in, uint8_t *out, uint32_t len)
    {
        AES_KEY realKey;
        AES_set_decrypt_key((uint8_t *)(m_key.c_str()), 128, &realKey);
        // len = (len % 16 == 0 ? len : (len / 16 + 1) * 16);
        AES_cbc_encrypt(in, out, len, &realKey, (uint8_t *)(m_ivec.c_str()), AES_DECRYPT);
    }
}